

$(function(){
	var $articles=$("#articles");
	$.ajax({
		type:"get",
		url:"http://192.168.13.194/blog/listArticle",
		cache:false,
		timeout:5000,
		success:function(data){
		
		var articles = data.result.list;
		console.log(articles);
		for(var i = 0;i<articles.length;i++){
			var html=[];
			var article=articles[i];
			html.push('<div class="bl-title row">');
			html.push('		<div class="col-xs-3">');
			html.push('			<img src="img/j1.jpg" class="img-responsive bl-img-j" alt="Responsive image" >');
			html.push('		</div>');
			html.push('		<div class="col-xs-9">');
			html.push('			<h4><a href="">'+article.title+'</a></h4>');
			html.push('			<p>'+article.lead+'</p>');
			html.push('			<p class="item">');
			html.push('				<span class="glyphicon glyphicon-th-large"></span><span class="classify">分类:'+article.category_name+'</span>');
			html.push('				<span class="glyphicon glyphicon-time"></span><span class="introduce-time">发布时间：'+article.create_time+'</span>');
			html.push('				<span class="glyphicon glyphicon-heart"></span><span class="read">阅读次数(<span class="read-more">'+article.read_times+'</span>)</span>');
			html.push('			</p>');
			html.push('		</div>');
			html.push('	</div>		');
			
			$articles.append(html.join(""));

			}

		},
		error:function(){
			$articles.append('<li><div class="alert alert-danger"><b>接口错误!</b>有可能是服务器内部错误或请求超时</div></li>')

		},
		beforeSend:function(){
			$articles.append('<li class="text-center"><i class="fa fa-cog fa-spin fa-3x fa-fw"></i></li>');
			
		},
		complete:function(){
			$articles.children('.text-center').remove();
		}
		
	});
	
//	$.get("http://192.168.13.194/blog/listArticle",{date:new Date().getTime()},function(data){
//		var articles = data.result.list;
//		console.log(articles);
//		for(var i = 0;i<articles.length;i++){
//			var html=[];
//			var article=articles[i];
//			html.push('<div class="bl-title row">');
//			html.push('		<div class="col-xs-3">');
//			html.push('			<img src="img/j1.jpg" class="img-responsive bl-img-j" alt="Responsive image" >');
//			html.push('		</div>');
//			html.push('		<div class="col-xs-9">');
//			html.push('			<h4><a href="">'+article.title+'</a></h4>');
//			html.push('			<p>'+article.lead+'</p>');
//			html.push('			<p class="item">');
//			html.push('				<span class="glyphicon glyphicon-th-large"></span><span class="classify">分类:'+article.category_name+'</span>');
//			html.push('				<span class="glyphicon glyphicon-time"></span><span class="introduce-time">发布时间：'+article.create_time+'</span>');
//			html.push('				<span class="glyphicon glyphicon-heart"></span><span class="read">阅读次数(<span class="read-more">'+article.read_times+'</span>)</span>');
//			html.push('			</p>');
//			html.push('		</div>');
//			html.push('	</div>		');
//			
//			$("#articles").append(html.join(""));
//			
//			
//		}
//		
//	},"json")
//	
	$.get("http://192.168.13.194/blog/listReadRank",{date:new Date().getTime()},function(data){
			var readRank=data.result;
			console.log(readRank);
			for(var i = 0;i<readRank.length;i++){
			var html=[];
			var readRank1=readRank[i];
			html.push('		<li class="list-group-item text-style"><span class="badge">'+readRank1.read_times+'</span><a href="" class="text-style">'+readRank1.id+"."+readRank1.title+'</a></li>');

			$("#readRank").append(html.join(""));
			}

		},"json")


	
});


